package com.amado.course08ArrayTwo;

//1. 定义数组如下:
//	   int[][] array ={ {30, 1, 22, 55, 81, 92},
//	                    {22, 48,36, 2,  12, 15},
//			    		{61, 4, 8,  9,  88, 99},
//			    		{52, 53,35, 6,  71, 920},
//			    		{10, 17,19, 91, 203,34},
//			    		{124,24,51, 59, 97, 78}
//			  };
//(7). 请找出数组中的最大值与最小值，请将最大值与最小值交换。 最后请打印整个数组？

public class ArrayTwo1 {
	public static void main(String[] args) {
		int[][] array = { { 30, 1, 22, 55, 81, 92 }, { 22, 48, 36, 2, 12, 15 }, { 61, 4, 8, 9, 88, 99 },
				{ 52, 53, 35, 6, 71, 920 }, { 10, 17, 19, 91, 203, 34 }, { 124, 24, 51, 59, 97, 78 } };
		int temp = 0;

		for (int x = 0; x < 3; x++) {
			int lastRow = array.length - 1;
			int lastCol = array[lastRow].length - 1;
			// 78
			
			for (int i = array.length - 1; i >= 0; i--) {
				for (int j = array[i].length - 1; j >= 0; j--) {
					if (i == array.length - 1 && j == array[i].length - 1) {
						temp = array[i][j];
						continue;
					}
					System.out.println(" " + i + "  " + j + " " + lastRow + "  " + lastCol);
					//5,5=5,4
					//5,4=5,3
					//5,3=5,2
					//5,2=5,1
					//5,1=5,0
					//5,0=4,5 //lastRow--,lastCol=array.length - 1
					//4,5=4,4
					array[lastRow][lastCol--] = array[i][j];
					if (lastCol < 0) {
						lastCol = array.length - 1;
						lastRow--;
					}
				}
			}
			array[0][0] = temp;
		}
		for (int[] tempArray : array) {
			for (int value : tempArray) {
				System.out.print(value + " ");
			}
			System.out.println();
		}
	}
}
